//
//  MyScroller.m
//  weibo3
//
//  Created by Tian Wu on 11-4-24.
//  Copyright 2011年 nfsysu. All rights reserved.
//

#import "MyScroller.h"
#import "PXListView.h"
#import "RootViewController.h"



@implementation MyScroller

@synthesize isDragging;


+(CGFloat) scrollerWidth{
    return 8;
}

+(CGFloat) scrollerWidthForControlSize:(NSControlSize)controlSize{
    return 8;
}

- (void) drawBackground:(NSRect) rect{
    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:0 yRadius:0];
    [[NSColor colorWithCalibratedRed:0.95 green:0.95 blue:0.95 alpha:0.98] set];
    [path fill];
    
}


- (void)mouseDown:(NSEvent *)theEvent{
    
    isDragging = YES;
    [super mouseDown:theEvent];
    isDragging = NO;
    extern RootViewController * rootView;
    [[rootView listView] contentViewBoundsDidChange:nil];
}


- (void)drawKnob{
    [self drawBackground:[self rectForPart:0]];
    [self drawBackground:[self rectForPart:1]];
    [self drawBackground:[self rectForPart:2]];
    [self drawBackground:[self rectForPart:4]];
    [self drawBackground:[self rectForPart:5]];
    [self drawBackground:[self rectForPart:6]];
    NSRect knobRect = [self rectForPart:NSScrollerKnob];
    NSRect newRect = NSMakeRect(knobRect.origin.x+3, knobRect.origin.y, knobRect.size.width - 6, knobRect.size.height);
    NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect 
                                                         xRadius:5 
                                                         yRadius:5];
    
    [path setLineWidth:2];
    [[NSColor colorWithDeviceRed:0.114 green:0.114 blue:0.114 alpha:0.3] set];
    [path fill];
    [[NSColor colorWithDeviceWhite:1.0 
                             alpha:0.100] set];
    
    [path addClip];
    [path stroke];

}
@end